#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int MAXN = 1e5+10;

int n,col[MAXN],mx,mn,k,kn[MAXN]; bool v[MAXN];
vector<int> T[MAXN],c[MAXN];

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	mn = 1e7;
	n = in;
	for(int i = 1;i < n;i++){
		int x = in,y = in;
		T[x].pb(y); T[y].pb(x);
	}
	k = in;
	for(int i = 1;i <= k;i++) kn[i] = in,col[kn[i]] = in,mx = max(mx,col[kn[i]]),mn = min(mn,col[kn[i]]);
	if(mx - mn > n) {puts("No");return 0;}
	for(int i = 1;i <= k;i++) c[col[kn[i]]-mn].pb(kn[i]),v[kn[i]] = 1;
	for(int i = 0;i < n;i++){
		for(int x : c[i]){
			for(int d : T[x]){
				if(!v[d]){
					v[d] = 1;
					col[d] = col[x] + 1;
					c[col[d]-mn].pb(d);
				}
			}
		}
	}
	for(int i = 1;i <= n;i++)
		for(int y : T[i]){
			if(col[y] - col[i] != 1 && col[y] - col[i] != -1){
				puts("No"); return 0;
			}
		}
	puts("Yes"); for(int i = 1;i <= n;i++) printf("%d\n",col[i]);
	return 0;
}

